package com.itheima.controller.backend.security;

import com.itheima.common.entity.Result;
import com.itheima.pojo.BusinessReportVO;
import com.itheima.pojo.MemberReportVO;
import com.itheima.pojo.SetmealReportVO;
import com.itheima.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@Slf4j
@RequestMapping("/report")
public class ReportController {
    @Autowired
    private ReportService reportService;

    /**
     * 会员数量统计数据
     *
     * @return
     */
    @GetMapping("/getMemberReport")
    public Result getMemberReport() {
        log.info("会员数量统计数据");
        MemberReportVO reportVO = reportService.getMemberReport();
        return Result.success(reportVO);
    }

    /**
     * 套餐占比统计数据
     *
     * @return
     */
    @GetMapping("/getSetmealReport")
    public Result getSetmealReport() {
        log.info("套餐占比统计数据");
        SetmealReportVO reportVO = reportService.getSetmealReport();
        return Result.success(reportVO);
    }

    /**
     * 运营统计数据
     *
     * @return
     */
    @GetMapping("/getBusinessReportData")
    public Result getBusinessReportData() {
        log.info("运营统计数据");
        BusinessReportVO reportVO = reportService.getBusinessReport();
        return Result.success(reportVO);
    }

    /**
     * 导出运营数据
     *
     * @return
     */
    @GetMapping("/exportBusinessReport")
    public void exportBusinessReport(HttpServletResponse response) {
        log.info("导出运营数据");
        BusinessReportVO reportVO = reportService.getBusinessReport();
        reportService.exportBusinessReport(response, reportVO);
    }
}
